<template>
  <div class="socialBox">
    <!-- Dom内容 -->

    <div class="header">
      <div class="header_search" @click="searchClick">
        <span class="span_icon">
          <i class="iconfont icon-fangdajing i_search"></i>
          搜索书圈、作者、帖子
        </span>
      </div>
      <div class="header_menu">
        <i class="iconfont icon-caidan2"></i>
      </div>
    </div>
    <div class="nav">
      <div
        v-for="(item, index) in navList"
        :key="index"
        @click="navClick(item, index)"
        :class="$route.path === item.path ? 'navActive' : ''"
      >
        {{ item.meta.name }}
        <span
          :class="$route.path === item.path ? 'borderActive Span' : 'Span'"
        ></span>
      </div>
    </div>
    <div class="social_main">
      <router-view />
    </div>
    <div class="zzTip">没有更多了</div>
  </div>
</template>

<script>
// import a from './a'; // 引入组件
export default {
  name: "",
  name: "",
  data() {
    return {
      msg: "测试",
      navList: [],
    };
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {

    this.navList = this.footerList = this.$router.options.routes.filter(
      (item) => {
        return item.name === "social";
      }
    );
    this.navList = this.navList[0].children.filter((item) => {
      return item.hidden !== true;
    });
  },
  // Vue方法定义
  methods: {
    navClick(item, i) {
      this.$router.history.push(item.path);
      localStorage.setItem("social-nowIndex", i);
      this.nowIndex = i;
    },
    searchClick() {
      this.$store.commit("bags/queryPath",this.$route.path)
       this.$router.history.push({
                        path:'/search',
                        query:{
                            path:this.$route.path
                        }
                    })
    },
  },
};
</script>

<style scoped>
/* @import url(''); 引入css类 */
@import url('../../../static/fonts/iconfont.css');
.socialBox{
  height: calc(100vh - 1.4944rem);
}
.header {
  padding-top: 10px;
  display: flex;
  position: relative;
  z-index: 2;
  background: white;
  width: 100%;
}
.header_search {
  width: 77%;
  height: 0.88rem;
  margin-left: 0.533333rem;
  border-radius: 999em;
  background: #f5f7f7;
}
.header_menu {
  width: 23%;
  height: 0.8rem;
  text-align: center;
}
.header_menu > i {
  width: 0.8rem;
  height: 0.8rem;
  display: inline-block;
  font-size: 0.533333rem;
  text-align: center;
  line-height: 0.88rem;
  margin-left: 0.4rem;
  transform: rotateY(180deg);
}
.span_icon {
  display: inline-block;
  padding: 7px 15px;
  color: #8a8a8a;
  font-size: 0.373333rem;
}
.i_search {
  display: inline-block;
  height: 0.68rem;
  color: #b3b3b3;
}

.navActive {
  font-weight: 900;
  font-size: 0.533333rem;
}

.nav {
  font-size: 0.48rem;
  display: flex;
  justify-content: space-between;
  width: 92%;
  margin: -0.1rem auto .1rem;
  position: relative;
  z-index: 2;
  background: white;
  padding-top: .4rem;
}
.nav>div{
  width: 25%;
  text-align: center;
}
.social_main {
  position: relative;
  z-index: 2;
  height:calc(100vh - 4.01rem) ;
  overflow: hidden;
}
.Span {
  display: block;
  height: 0.16rem;
  width: 40%;
  margin: 0.1rem auto 0;
  border-radius: 999em;
  transition: all 0.4s linear;
}
.borderActive {
  background: #f33a65;
}
.zzTip {
  width: 100vw;
  min-height: 0.8rem;
  position: fixed;
  bottom: 1.6rem;
  text-align: center;
  z-index: 1;
  color: #b3b3b3;
}
</style>